from bs4 import BeautifulSoup


hxml_str = """
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title id="101" name="qiku">Title</title>
</head>
<body>
<ul>
    <li id="li1">li1</li>
    <li id="li2">li2</li>
    <li id="li3">li3</li>
</ul>

<ol>
    <li id="li11"><a href="https://www.baidu.com">百度</a></li>
    <li id="li22"><a href="https://www.jd.com">京东</a></li>
    <li id="li33"><a href="https://www.taobao.com">淘宝</a></li>
</ol>

<h1><a href="https://www.pdd.com">拼多多</a></h1>
</body>
</html>
"""


soup = BeautifulSoup(markup=hxml_str, features="lxml")

# print(soup.prettify())

# print(type(soup), dir(soup))

# print(soup.title, type(soup.title), dir(soup.title))

# title = soup.title
# print(title.text, title.string, title.get_text())
# print(title.attrs)


# lis = soup.find_all('li')
# for li in lis:
#     print(type(li), li, li.text, li.attrs['id'])

# a = soup.find("a", attrs={"href": "https://www.pdd.com"})
# print(a, a.text)


# ol = soup.find("ol")
# lis = ol.find_all("li")
# for li in lis:
#     print(li.text, li.attrs["id"])



# print(dir(soup.css))

# title = soup.css.select_one("title")
# print(title, type(title))

# lis = soup.css.select("ol li")
# for li in lis:
#     print(li, type(li))

